package main

import (
	"os"
	"fmt"
	"io"
	"net"
)

func main() {
	tcpaddr, _ := net.ResolveTCPAddr("tcp", ":5555")
	listener, _ := net.ListenTCP("tcp", tcpaddr)
	for{
		conn, _ := listener.Accept()
		srcname := "/home/xiaonu/Desktop/Go语言编程 快捷方式.pdf"
		file1, _ := os.Open(srcname)
		bs := make([]byte, 1024)
		for {
			n, err := file1.Read(bs)
			if err == io.EOF {
				fmt.Println("发送完了")
				file1.Close()
				break
			}
			fmt.Println(bs[:n])
			conn.Write(bs[:n])
		}
		conn.Close()
	}

}
